package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.PaymentBalanceDistributorEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author zcp
 */
@Getter
public enum TempPrepaymentBalanceDistributorEnum {
    //
    ADVANCE_PAYMENT_BALANCE(PaymentBalanceDistributorEnum.ADVANCE_PAYMENT_BALANCE),
    CUSTOMER_ID(PaymentBalanceDistributorEnum.CUSTOMER_ID),
    CUSTOMER_NAME(PaymentBalanceDistributorEnum.CUSTOMER_NAME),
    CONTRACT_COUNT(PaymentBalanceDistributorEnum.CONTRACT_COUNT),
    OWNER_ID(PaymentBalanceDistributorEnum.OWNER_ID),
    CREATOR_ID(PaymentBalanceDistributorEnum.CREATOR_ID),
    ADD_TIME(PaymentBalanceDistributorEnum.ADD_TIME),
    UPDATE_TIME(PaymentBalanceDistributorEnum.UPDATE_TIME),
    ;

    private PaymentBalanceDistributorEnum anEnum;

    TempPrepaymentBalanceDistributorEnum(PaymentBalanceDistributorEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempPrepaymentBalanceDistributorEnum> getAllEnum() {
        List<TempPrepaymentBalanceDistributorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initContractCount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initCustomerId(FieldAttrEntity fieldAttrEntity) {
        //特殊处理，只有导出用到，不置成客户的100,防止被解析成子表单
        //不能使用RedundantTemplateTypeEnum内的预收款余额PREPAYMENT_BALANCE，因为其会转为回款单的预收款类型
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PREPAYMENT_BALANCE.getCode());
        fieldAttrEntity.setLinkedText(CUSTOMER_NAME.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDisableListSort(1);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }
    public static void initAdvancePaymentBalance(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
    }
}
